package com.guigu.pd.oms.controller;

import java.util.Arrays;
import java.util.Map;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.guigu.pd.serviceapi.pojo.OrderCargoEntity;
import com.guigu.pd.oms.service.OrderCargoService;
import com.guigu.common.utils.PageUtils;
import com.guigu.common.utils.R;



/**
 * 货品总重量 
 *
 * @author deyran
 * @email deyran@gmail.com
 * @date 2022-07-19 19:29:39
 */
@RestController
@RequestMapping("oms/ordercargo")
public class OrderCargoController {
    @Autowired
    private OrderCargoService orderCargoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = orderCargoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
		OrderCargoEntity orderCargo = orderCargoService.getById(id);

        return R.ok().put("orderCargo", orderCargo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody OrderCargoEntity orderCargo){
		orderCargoService.save(orderCargo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody OrderCargoEntity orderCargo){
		orderCargoService.updateById(orderCargo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody String[] ids){
		orderCargoService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    @GetMapping("/getordercargobyid/{id}")
    public OrderCargoEntity getordercargobyId(@PathVariable("id") String id){
        QueryWrapper<OrderCargoEntity> queryWrapper = new QueryWrapper<OrderCargoEntity>();
        queryWrapper.eq("order_id",id);
        OrderCargoEntity orderCargo = orderCargoService.getOne(queryWrapper);

        return orderCargo;
    }

}
